<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      html,
      body {
        height: 100%;
      }
      * {
        margin: 0;
        padding: 0;
      }
      canvas {
        border: 1px solid black;
        margin: 0 auto;
        display: block;
      }
    </style>
  </head>
  <body>
    <canvas width="500" height="500">浏览器版本过低</canvas>
    <script>
      // 获取画布
      const canvas = document.querySelector('canvas');
      // 获取画笔
      const c = canvas.getContext('2d');
      // 设置字体样式
      c.font = '100px 微软雅黑';
      // 设置文字颜色
      c.fillStyle = 'red';
      // 画文字
      c.fillText('Hello', 250, 250, 200);

      // 绘制空心文字
      c.strokeStyle = 'red';
      c.strokeText('你好', 0, 250);
    </script>
  </body>
</html>
